home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH3 / SRC / RELATIVE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-02-03  |  3.5 KB  |  128 lines

  1. VERSION 4.00
  2. Begin VB.Form RelativeForm 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "Relative"
  5.    ClientHeight    =   2985
  6.    ClientLeft      =   1950
  7.    ClientTop       =   1905
  8.    ClientWidth     =   4860
  9.    Height          =   3675
  10.    Left            =   1890
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   199
  13.    ScaleMode       =   3  'Pixel
  14.    ScaleWidth      =   324
  15.    Top             =   1275
  16.    Width           =   4980
  17.    Begin VB.PictureBox RelativePict 
  18.       AutoRedraw      =   -1  'True
  19.       Height          =   2700
  20.       Left            =   2445
  21.       ScaleHeight     =   2640
  22.       ScaleWidth      =   2340
  23.       TabIndex        =   1
  24.       Top             =   0
  25.       Width           =   2400
  26.    End
  27.    Begin VB.PictureBox RGBPict 
  28.       AutoRedraw      =   -1  'True
  29.       Height          =   2700
  30.       Left            =   0
  31.       ScaleHeight     =   2640
  32.       ScaleWidth      =   2340
  33.       TabIndex        =   0
  34.       Top             =   0
  35.       Width           =   2400
  36.    End
  37.    Begin VB.Label Label1 
  38.       Alignment       =   2  'Center
  39.       Caption         =   "Palette Relative RGB"
  40.       Height          =   255
  41.       Index           =   1
  42.       Left            =   2445
  43.       TabIndex        =   3
  44.       Top             =   2760
  45.       Width           =   2400
  46.    End
  47.    Begin VB.Label Label1 
  48.       Alignment       =   2  'Center
  49.       Caption         =   "RGB"
  50.       Height          =   255
  51.       Index           =   0
  52.       Left            =   0
  53.       TabIndex        =   2
  54.       Top             =   2760
  55.       Width           =   2400
  56.    End
  57.    Begin VB.Menu mnuFile 
  58.       Caption         =   "&File"
  59.       Begin VB.Menu mnuFileExit 
  60.          Caption         =   "E&xit"
  61.       End
  62.    End
  63. Attribute VB_Name = "RelativeForm"
  64. Attribute VB_Creatable = False
  65. Attribute VB_Exposed = False
  66. Option Explicit
  67. ' ***********************************************
  68. ' Fill picture boxes with shades of color.
  69. ' ***********************************************
  70. Sub FillPictures()
  71. Const NUM_COLS = 16
  72. Const ROWS_PER_COLOR = 4
  73. Const NUM_ROWS = ROWS_PER_COLOR * 3
  74. Const NUM_BOXES = ROWS_PER_COLOR * NUM_COLS
  75. Dim dx As Single
  76. Dim dy As Single
  77. Dim x As Single
  78. Dim y As Single
  79. Dim clr As Integer
  80. Dim dr As Integer
  81. Dim dg As Integer
  82. Dim db As Integer
  83. Dim i As Integer
  84. Dim j As Integer
  85. Dim r As Integer
  86. Dim g As Integer
  87. Dim b As Integer
  88.     dx = RGBPict.ScaleWidth / NUM_COLS
  89.     dy = RGBPict.ScaleHeight / NUM_ROWS
  90.     For clr = 1 To 3
  91.         dr = 0
  92.         dg = 0
  93.         db = 0
  94.         Select Case clr
  95.             Case 1  ' Shades of red.
  96.                 dr = 255 / NUM_BOXES
  97.             Case 2  ' Shades of green.
  98.                 dg = 255 / NUM_BOXES
  99.             Case 3  ' Shades of blue.
  100.                 db = 255 / NUM_BOXES
  101.         End Select
  102.         
  103.         r = 0
  104.         g = 0
  105.         b = 0
  106.         For i = 1 To ROWS_PER_COLOR
  107.             x = 0
  108.             For j = 1 To NUM_COLS
  109.                 RGBPict.Line (x, y)-Step(dx, dy), _
  110.                     RGB(r, g, b), BF
  111.                 RelativePict.Line (x, y)-Step(dx, dy), _
  112.                     RGB(r, g, b) + &H2000000, BF
  113.                 r = r + dr
  114.                 g = g + dg
  115.                 b = b + db
  116.                 x = x + dx
  117.             Next j
  118.             y = y + dy
  119.         Next i
  120.     Next clr
  121. End Sub
  122. Private Sub Form_Load()
  123.     FillPictures
  124. End Sub
  125. Private Sub mnuFileExit_Click()
  126.     Unload Me
  127. End Sub
  128.